<!-- The ref attr used to find the swiper instance -->
<template>
  <div class="sw-wrapper">
    <swiper :options="swiperOption" v-if="isSwiperShow">
      <!-- slides   @someSwiperEvent="callback"-->
      <swiper-slide v-for="item in swiperList" :key="item.id" >
        <img
          class="swiper-img"
          :src="item.imgUrl"
        />
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: "HomeSwiper",
  props: {
    swiperList: Array
  },
  data: function() {
    return {
      swiperOption: {//分页器
        pagination: '.swiper-pagination',
        loop:true,
        autoplay: 2800
      },
      // swiperList: [,{},{},{}]
    };
  },
  computed: {
    isSwiperShow: function() {
      return this.swiperList.length;
    }
  }
};
</script>

<style lang="stylus" scoped>
.sw-wrapper >>> .swiper-pagination-bullet-active {
  background-color: #fff;
} 

.sw-wrapper {
  width: 100%;
  height: 0;
  padding-bottom: 26.67%;
  background-color: #eee;
}

.sw-wrapper .swiper-img {
  width: 100%;
  height: 100%;
}
</style>
